# Harris 1969 Changing Morality Survey, study no. 1933
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1969 Changing Morality Survey, study no. 1933")
## packages
require("SASxport")
require("dplyr")
## download data
survey <- read.xport("harris_s1933_sas.export")
## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)
## study number
survey$study <- as.character(1933)
class(survey$study)
## year
survey$year <- 1969
class(survey$year)
## geographpic data
survey$urban <- NA
class(survey$urban)
## region
survey$region <- NA
## respondent name
survey$hh <- NA
## inequality increasing
summary(survey$Q10A.1)
survey$inequality <- survey$Q10A.1
class(survey$inequality)
is.ordered(survey$inequality)
## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)
## union
survey$union.self <- NA
survey$union.other <- NA
## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- survey$F2A
class(survey$employed)
## Occupation
summary(survey$F2B)
survey$occupation <- survey$F2B
class(survey$occupation)
## household size
survey$hhsize <- NA
## Education
summary(survey$F3C)
survey$educ <- survey$F3C
survey$educ <- recode(survey$educ, `8th grade or less` = "Less than high school",
`some high school` = "Less than high school",
`High school diploma` = "High school graduate",
`2-yr cllg grdt (cmmnty cllg, tc )` = "Some college",
`4-year college graduate` = "College graduate",
`post graduate` = "Post graduate")
levels (survey$educ)
summary(survey$educ)
summary(survey$F3C)
survey$educ <- ordered(survey$educ,
levels = c("Less than high school", "High school graduate",
"Some college", "College graduate",
"Post graduate"))
class(survey$educ)
is.ordered(survey$educ)
## Income
summary(survey$F6)
survey$income <- survey$F6
summary(survey$income)
class(survey$income)
## Age
summary(survey$F5C.1)
summary(survey$F5C.2)
sum(!is.na(survey$F5C.1) & !is.na(survey$F5C.2))
sum(is.na(survey$F5C.1) & is.na(survey$F5C.2))
survey[!is.na(survey$F5C.1) & !is.na(survey$F5C.2), c("S1", "F5C.1", "F5C.2")]
survey$F5C.2[1412] <- NA
survey$age <- ifelse(is.na(survey$F5C.1), as.character(survey$F5C.2), as.character(survey$F5C.1))
survey$age <- factor(survey$age)
class(survey$age)
summary(survey$age)
## race
summary(survey$F7)
survey$race <- survey$F7
class(survey$race)
## politics
survey$party <- survey$A1D
class(survey$party)
## ideology
survey$ideology <- NA
## gender
summary(survey$S1)
survey$gender <- survey$S1
class(survey$gender)
## religion
summary(survey$F5A)
survey$religion <- survey$F5A
class(survey$religion)
### put together data set
survey_1933 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_1933)
## save dataset in folder (i.e. working directory must be set to folder)
saveRDS(survey_1933, file = "survey_1933.rds")
